import React, { Component } from "react";
import more from "@assets/img/more.png";
import "./index.scss";

export default class HomeCates extends Component {
  render() {
    return (
      <div className="sh_cb">
        <ul className="catesul">
          {
            this.props.cates.map((item) => (
              <li key={item.id} onClick={() => this.goItemlist(item.id)}>
                <div>
                  <img src={item.icon} alt={item.name} />
                </div>
                <p>{item.name}</p>
              </li>
            ))
          }
          <li>
            <div>
              <img src={more} alt="查看更多" onClick={() => this.goMoreCates("/cates")} />
            </div>
            <p>查看更多</p>
          </li>
        </ul>
      </div>
    )
  }
  // 点击更多去分类页(子组件给父组件传参)
  goMoreCates = (value) => {
    this.props.goMoreCates(value);
  }
  // 去分类商品列表
  goItemlist = (value) => {
    this.props.goItemlist(value);
  }
}
